package Thread;
class Mythread5 extends Thread{
    @Override
    public void run() {
        //在这个代码中如果想获取线程的引用使用this即可
        System.out.println(this.getId()+","+this.getName());
    }
}
public class ThreadDemo16 {
    public static void main(String[] args) throws InterruptedException {
        //如果是继承自Thread类直接使用this即可，如果是继承runnable，或者lambda表达式那么this就无能为力了，此时需要使用Thread.currentThread()，来获取当前对象
        Thread thread = new Mythread5();
        Thread thread1 = new Mythread5();
        thread.start();
        thread1.start();
        Thread.sleep(1000);
        System.out.println(thread.getId()+","+thread.getName());
        System.out.println(thread1.getId()+","+thread1.getName());
    }
}
